﻿using System;

class SortArrayByLengthOfElements

            // You are given an array of strings. Write a method that sorts the array by the length of its elements (the number of characters composing them).

{
    static void Main()
    {
        Console.Write("Enter the length of the array: ");
        int arraySize = int.Parse(Console.ReadLine());
        string[] array = new string[arraySize];
        int[] length = new int[arraySize];
        Console.WriteLine();

        Console.WriteLine("Enter the elements of the array: ");
        for (int i = 0; i < arraySize; i++)
        {
            array[i] = Console.ReadLine();
            length[i] = array[i].Length;
        }
        Console.WriteLine();

        Array.Sort(length, array);

        Console.WriteLine("When sorted by the length of its elements, the arrray looks like:");
        for (int i = 0; i < arraySize; i++)
        {
            Console.Write(array[i] + " ");
        }
        Console.WriteLine();
    }
}

